package com.sun.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;

/**
 * @Project: hospitalDrugInformationManagement
 * @Author: 86178
 * @Date: 2023/3/26 16:53
 * @FileName: dateUtils
 * @Description: "日期工具类"
 */
@SuppressWarnings("all")
public class DateUtils {

    //计算一个日期和时间后的日期
    public static LocalDateTime calculate(LocalDateTime time, Integer day) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sdf.parse(String.valueOf(time));
        Calendar cl = Calendar.getInstance();
        cl.setTime(date);
        cl.add(Calendar.DATE, day);
        String temp = "";
        temp = sdf.format(cl.getTime());
        return LocalDateTime.parse(temp);
    }
}
